<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 400px;
            height: 400px;
            background: skyblue;
        }

        /*  ::before 往前追加一个伪元素  */
        div::before {
            /* content设置元素里面文本 */
            content: '我是伪元素';
            /* 默认是行内元素 */
            display: block;
            width: 100px;
            height: 100px;
            background: orange;
        }

        /* ::after 往后追加一个伪元素  */
        div::after {
            content: '需要就写，不需要就不写';
            display: block;
            width: 100px;
            height: 100px;
            background: palevioletred;
        }
    </style>
</head>

<body>
    <!-- 伪元素 -->
    <div>
        <p>1</p>
    </div>
</body>

</html>